16 2024

Upgrading Spring season Investigation People wasn’t effortless, but which had absolutely nothing to do with Spring season Investigation Rest alone

0 Comment

That being said, it might not make sense to do this. I cannot inquire the developers why it had been done so method, they aren’t here any more. Which project’s tale is only able to be told along with their Git background.

Coaching discovered mujeres Irlanda en lГ­nea upgrading Springtime Research Other people

We believe our company is having fun with Spring season Investigation People incorrect, improperly combination WebMVC rules. When we had not done this right away, something will have work on much smoother.

We have been now carried out with new Springtime Data Rest migration. It is time to move on to the 2nd Springtime module, Spring Kafka.

Springtime Kafka

Spring season Kafka, or rather Spring season having Apache Kafka , is a great way to use Kafka on the Spring ideas. It offers simple-to-have fun with layouts having giving messages and you may typical Springtime annotations getting taking messages.

Configuring the new consumers

step one [ERROR] coffee.lang.IllegalStateException: Did not weight ApplicationContext 2 step 3 Considering: org.springframework.beans.warehouse.BeanCreationException: Error carrying out bean having name 'consumerFactory' outlined in classification roadway money [ de / application / config / KafkaConsumerConfig . class ]: cuatro 5 Caused by: java . lang . NullPointerException 6 at java . legs / java . util . concurrent . ConcurrentHashMap . putVal ( ConcurrentHashMap . java: ten11 ) eight at java . base / java . util . concurrent . ConcurrentHashMap . init >( ConcurrentHashMap . java: 852 ) 8 at org . springframework . kafka . center . DefaultKafkaConsumerFactory . init >( DefaultKafkaConsumerFactory . java: 125 ) nine at org . springframework . kafka . core . DefaultKafkaConsumerFactory . init >( DefaultKafkaConsumerFactory . java: 98 ) 10 at de . app . config . KafkaConsumerConfig . consumerFactory ( AbstractKafkaConsumerConfig . java: 120 ) 

It turns out, we had been configuring the consumerConfigs bean and setting null values in its properties. The following change from HashMap to ConcurrentHashMap means we can no longer configure null values. We refactored our code and now tests are green. Easy-peasy.

Kafka messages with JsonFilter


1 [ERROR] org .apache .kafka mon .problems .SerializationException : Can 't serialize data [Experiences [payload=MyClass(Id=201000000041600097, . ] having thing [my-topic] 2 3 For the reason that: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Usually do not look after PropertyFilter which have id ‘myclassFilter' ; zero FilterProvider configured (due to resource strings: de- .take to .Knowledge [ "payload" ] ) 4 at the com .fasterxml .jackson .databind .exc .InvalidDefinitionException .regarding (InvalidDefinitionException .java : 77 ) 

Some of our Java Beans use ato manipulate the serialization and deserialization. This requires a propertyFilter to be configured on the ObjectMapper.
Spring for Apache Kafka made a change to the JsonSerializer , introducing an ObjectWriter . When the ObjectWriter instance is created, the ObjectMapper configuration is copied, not referenced. Our test case was re-configuring the ObjectMapper with the appropriate propertyFilter after the ObjectWriter instance was created. Hence, the ObjectWriter didn't know anything about the propertyFilter (since the configuration was already copied). After some refactoring, changing how we create and configure the JsonSerializer , our test cases were green.
Running our build $ mvn clean verify finally resulted in a green build. Everything is working as it should. We pushed our changes to Bitbucket and everything built like a charm.

Coaching read upgrading Spring season Kafka


Courses discovered throughout the Spring Boot enhance


Spring and Spring Boot do a great job documenting their releases, their release notes are well maintained. That being said, upgrading was challenging, it took quite a while before everything was working again. A big part of that is on us, for not following best practices, guidelines, etc. A lot of this code was written when the team was just starting out with Spring and Spring Boot. Code evolves over time, without refactoring and applying those latest practices. Eventually that catches up with you, but we use this as a learning experience and improved things. Our test cases are now significantly better, and we'll keep a closer eye on them moving forward.
[top]
About the Author


Leave a Reply

电子邮件地址不会被公开。 必填项已用 * 标注

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>